package com.lazy.dao;

import com.lazy.entity.BicycleType;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BicycleTypeDao {

    @Insert("insert into t_bicycle_type values(null,#{typeName},#{detain},#{rent},#{purchasePrice})")
    boolean addBicycleType(BicycleType bicycleType);

    @Select("select * from t_bicycle_type where id=#{id}")
    @Results(id = "getBicycleTypeById",value = {
            @Result(id = true,property = "id",column ="id"),
            @Result(property = "typeName",column ="type_name"),
            @Result(property = "detain",column ="detain"),
            @Result(property = "rent",column ="rent"),
            @Result(property = "purchasePrice",column ="purchase_price"),
    })
    BicycleType getBicycleTypeById();

    @Select("select * from t_bicycle_type")
    @Results(id = "getAllBicycleType",value = {
            @Result(id = true,property = "id",column ="id"),
            @Result(property = "typeName",column ="type_name"),
            @Result(property = "detain",column ="detain"),
            @Result(property = "rent",column ="rent"),
            @Result(property = "purchasePrice",column ="purchase_price"),
    })
    List<BicycleType> getAllBicycleType();

    @Delete("delete from t_bicycle_type where id=#{id}")
    boolean deleteBicycleType(Integer id);

    @Update("update t_bicycle_type set type_name=#{typeName},detain=#{detain}" +
            ",rent=#{rent},purchase_price=#{purchasePrice} " +
            "where id=#{id}")
    boolean updateBicycleType(BicycleType bicycleType);
}

